﻿using System;
using System.Html.DOM;

namespace RexToy.UI.Controls
{
    public class Control : RexToy.Object, IControl
    {
        public virtual void Init()
        {
        }

        public virtual void Destroy()
        {
        }

        protected DomNode __domNode;
        public DomNode DomNode
        {
            get { return __domNode; }

        }
        protected bool __standalone;
        public virtual bool Standalone
        {
            get { return __standalone; }
            set { __standalone = value; }
        }

        protected Orientation __orientation;
        public virtual Orientation Orientation
        {
            get { return __orientation; }
            set { __orientation = value; }
        }

        protected Palette __palette;
        public virtual Palette Palette
        {
            get { return __palette; }
            set { __palette = value; }
        }

        protected Control __parent;
        public Control Parent
        {
            get { return __parent; }
            set { __parent = value; }
        }

        protected bool __selectable;
        public bool Selectable
        {
            get { return __selectable; }
            set { __selectable = value; }
        }

        protected bool __dragEnable;
        //Note: if the control support drag. (if support, startDrag/stopDrag/dragging will be called.)
        public bool DragEnable
        {
            get { return __dragEnable; }
            set { __dragEnable = value; }
        }

        protected bool __dragEventBubble;
        //Note: propagate the drag event. (if propagate, it will notify the parent.)
        public bool DragEventBubble
        {
            get { return __dragEventBubble; }
            set { __dragEventBubble = value; }
        }

        protected bool __isContainer;
        public bool IsContainer
        {
            get { return __isContainer; }
        }


        protected bool _initialized;

        public Control()
        {
        }

        //TODO:Similar to domNode evType, need event type define
        public void AttachEvent(string name, Delegate handler)
        {
        }

        public void DetachEvent(string name, Delegate handler)
        {
        }

        [ImportMember("__fireEvent")]
        protected void __FireEvent(string name)
        {
        }

        public void RenderInto()
        {
        }

        public void RenderInto(DomNode node)
        {
        }

        public void RenderInto(HtmlElement element)
        {
        }

        /// <summary>
        /// virtual method to be called when parent is resize/adjust layout.
        /// </summary>
        /// <param name="size"></param>
        public virtual void Render(Size size)
        {
        }

        public virtual void SetFirst(bool first)
        {
        }

        public virtual void SetLast(bool last)
        {
        }

        public virtual void Display(bool show)
        {
        }

        public Point GetAbsolutePosition()
        {
            return new Point(0, 0);
        }

        public virtual Size GetSize()
        {
            return new Size(0, 0);
        }

        public void SetWidth(int widht)
        {
        }

        public void SetHeight(int height)
        {
        }
    }
}
